using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMathLibrary.QuadPack
{
    /// <summary>
    /// DQAG - Approximation to definite integral.  
    /// </summary>
    [Serializable]
    public static class DqagClass
    {
        /// <summary>
        /// DQAG - Approximation to definite integral.
        /// </summary>
        /// <param name="f">Double precision function to be integrated.</param>
        /// <param name="a">Lower limit of integration.</param>
        /// <param name="b">Upper limit of integration.</param>
        /// <param name="epsabs">The absolute accuracy requested.</param>
        /// <param name="epsrel">The relative accuracy requested.</param>
        /// <param name="irule">The integration rule to be used as follows: irule = 1 -- G_K 7-15; irule = 2 -- G_K 10-21; irule = 3 -- G_K 15-31; irule = 4 -- G_K 20-41; irule = 5 -- G_K 25-51; irule = 6 -- G_K 30-61.</param>
        /// <param name="abserr">The requested absolute error of the result.</param>
        /// <param name="neval">The needed function evalations.</param>
        /// <param name="ier">The requested errorcode.</param>
        /// <returns>The result of the numerical integration.</returns>
        public static double Dqag(HardRealFunction f, double a, double b, double epsabs, double epsrel, int irule,
                                  ref double abserr, ref int neval, ref int ier)
        {
            int last = 0;
            double result = DqageClass.Dqage(f, a, b, epsabs, epsrel, irule, ref abserr, ref neval, ref ier, ref last);

            return result;
        }
    }
}